<!DOCTYPE html>
<html>
<head>
    <title>AI Solution Club</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>Welcome to AI Solution Club</h1>
    <form id="messageForm">
        <textarea id="message" placeholder="输入消息" rows="6" style="width: 500px; margin-bottom: 10px;"></textarea>
        <br>
        <button type="submit">发送</button>
    </form>
    <div id="response"></div>

    <script>
        document.getElementById('messageForm').onsubmit = async (e) => {
            e.preventDefault();
            const message = document.getElementById('message').value;
            try {
                const response = await fetch('/send', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ message })
                });
                const data = await response.json();
                document.getElementById('response').textContent = data.message;
            } catch (error) {
                console.error('Error:', error);
            }
        };
    </script>
</body>
</html>
